package bishizhuanyong.迅雷;


/*
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i=0;i<n;i++){
            int count = in.nextInt();
            if (count>0){
                Tire root=new Tire();
                boolean failflag=false;
                for (int j=0;j<count;j++){
                    String str = in.nextLine();
                    boolean fail = insert(root, str);
                    if (fail){
                        failflag=true;
                        break;
                    }
                }
                System.out.println(failflag==true?"NO":"YES");
            }
        }
    }


    static class Tire{
        int end=0;
        int pass=0;
        Tire[] childs=new Tire[10];
    }

    public static boolean insert(Tire root,String s){
        if (s==null||s.equals(" "))
            return false;
        char[] chars = s.toCharArray();
        Tire ptr=root;
        for (int i=0;i<chars.length;i++){
            int index=chars[i]-'0';
            if (ptr.childs[index]==null)
                ptr.childs[index]=new Tire();
            Tire tmp=ptr.childs[index];
            tmp.pass++;
            if (i== chars.length-1) {
                tmp.end++;
                if (tmp.end>1||tmp.pass>1)
                    return true;
            }
        }
        return false;
    }
}
2
3
911
97625999
91125426
5
113
12340
123440
12345
98346
 */
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i=0;i<n;i++){
            int count = in.nextInt();
            if (count>0){
                Tire root=new Tire();
                boolean failflag=false;
                for (int j=0;j<count;j++){
                    String str = in.next();
                    boolean fail = insert(root, str);
                    if (fail){
                        failflag=true;
                        break;
                    }
                }
                System.out.println(failflag==true?"NO":"YES");
            }
        }
    }


    static class Tire{
        int end=0;
        int pass=0;
        Tire[] childs=new Tire[10];
    }

    public static boolean insert(Tire root,String s){
        if (s==null||s.equals(" "))
            return false;
        char[] chars = s.toCharArray();
        Tire ptr=root;
        for (int i=0;i<chars.length;i++){
            int index=chars[i]-'0';
            if (ptr.childs[index]==null)
                ptr.childs[index]=new Tire();
            ptr=ptr.childs[index];
            ptr.pass++;
            if (i== chars.length-1) {
                ptr.end++;
                if (ptr.end>1||ptr.pass>1)
                    return true;
            }else {
                if (ptr.end>0)
                    return true;
            }
        }
        return false;
    }
}